#define _CRT_SECURE_NO_WARNINGS 1
#include<stdlib.h>

int cmp(const void* a, const void* b)
{
    return *(int*)a < *(int*)b;
}
int dominantIndex(int* nums, int numsSize) {
    int* tmp = (int*)malloc(sizeof(int) * numsSize);
    for (int i = 0; i < numsSize; i++)
    {
        tmp[i] = nums[i];
    }
    qsort(nums, numsSize, sizeof(int), cmp);
    if ((nums[1] != 0) && (nums[0] / nums[1] < 2))
        return -1;
    int i = 0;
    for (i = 0; i < numsSize; i++)
    {
        if (nums[0] == tmp[i])
            break;
    }
    return i;
}